﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace StuInformations
{
    class DBHelper
    {
        //查询
        public static DataSet Select(string sql)
        {
            string conStr = "Data Source=.;Initial Catalog=StudentDB;Integrated Security=True";
            SqlConnection con = new SqlConnection(conStr);
            con.Open();
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(sql,con);
            da.Fill(ds);
            return ds;
        }
        //增加、删除、修改
        public static int ExecuteNonQuery(string sql)
        {
            string conStr = "Data Source=.;Initial Catalog=StudentDB;Integrated Security=True";
            SqlConnection con = new SqlConnection(conStr);
            con.Open();
            SqlCommand cmd = new SqlCommand(sql,con);
            int row = cmd.ExecuteNonQuery();
            con.Close();
            return row; 
        }
    }
}
